<?php
include(dirname(__FILE__).'/top-bottom-share-data.php');
$GLOBALS['error_message'] = '';
$GLOBALS['login_success'] = FALSE;
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';
$dt = new DataTable(constant('DB_TABLE_MEMBER'));
if ( $act == 'login' ) {
	$email = $_REQUEST['email'];
	$password = $_REQUEST['password'];
	$password = md5($password);
	$condition = sprintf("`email`='%s' AND `password`='%s' and `status`='active'",Util::sql_safe($email), Util::sql_safe($password));
	$row = $dt->get_row($condition);
	if ( $row ) {
		SessionUtil::setVar(constant('SESSION_KEY_MEM_HAS_LOGIN'), true);
		SessionUtil::setVar(constant('SESSION_KEY_MEM_USER_ID'), $row['id']);
		SessionUtil::setVar(constant('SESSION_KEY_MEM_USER_NAME'), $row['nick_name']);
		SessionUtil::setVar(constant('SESSION_KEY_MEM_DISPLAY_NAME'), $row['display_name']);

		$GLOBALS['login_success'] = TRUE;
	}else{
		$GLOBALS['error_message'] = '用戶名或者密碼錯誤';
	}
}
?>